<?php
// 本类由系统自动生成，仅供测试用途
class RegisterAction extends BaseAction {
		
	
    public function index(){//注册页		
	     $this->display();	   
    }
	public function checkName(){//Ajax检测用户名		
	    $username = $_GET['username'];
		$user = M('User');
		//$where['username'] = $username;
		$count = $user->where(array('username'=>$username))->count(); 
		if($count){
			$this->ajaxReturn(00,"该用户名已被注册",1);
		}else{
			$this->ajaxReturn(00,"可以注册",0);

		}
    }
	public function doReg(){//Ajax检测用户名
		$username = $_POST['username'];
		$password = $_POST['password'];
		$repassword = $_POST['qr-password'];
		$sexy = $_POST['sexy'];
		
		$user = M('User');
		$data['username'] = $username;
		$data['password'] = $password;
		$data['sexy'] = $sexy;
		
		$lastid = $user->add($data);
		
		if($lastid){
			$this->redirect('Index/index');
		}else{
			$regError = "<span class='text-danger'>注册失败</span>";
			$this-assign('regError',$regError);
		}
		
		
		
	}

}